package spring.demo12.client;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.remoting.rmi.RmiProxyFactoryBean;

import spring.demo12.notuse.NotUseSpringRmiInterface;
import spring.demo12.use.MyRMIInterface;

public class ClientMain {
	public static void main(String[] args) throws RemoteException, NotBoundException, MalformedURLException {
		ClassPathXmlApplicationContext context = 
				new ClassPathXmlApplicationContext("SpringContext2.xml");
		MyRMIInterface a = context.getBean("myClient", MyRMIInterface.class);
		System.out.println(a.getName());
		
		Registry registry = LocateRegistry.getRegistry("localhost",2004);
		NotUseSpringRmiInterface va = (NotUseSpringRmiInterface)registry.lookup("userManager");
		System.out.println("不使用spring：" + va.getName());
	}
}
